#include <iostream>
using namespace std;
class Timer
{
public:
  Timer();
  Timer(int h, int m = 0);
  friend Timer operator+(Timer &t1, Timer &t2);
  friend Timer operator-(Timer &t1, Timer &t2);
  friend ostream &operator<<(ostream &out,
                             Timer &t);
  friend istream &operator>>(istream &in,
                             Timer &t);

private:
  int hours;
  int minutes;
};
Timer::Timer()
{
  hours = minutes = 0;
}
Timer::Timer(int h, int m)
{
  hours = h;
  minutes = m;
}
Timer operator+(Timer &t1, Timer &t2)
{
  Timer sum;
  sum.minutes = t1.minutes + t2.minutes;
  sum.hours = t1.hours + t2.hours + sum.minutes / 60;
  sum.minutes %= 60;
  return sum;
}
Timer operator-(Timer &t1, Timer &t2)
{
  Timer dif;
  int x1, x2;
  x1 = t2.hours * 60 + t2.minutes;
  x2 = t1.hours * 60 + t1.minutes;
  dif.minutes = (x2 - x1) % 60;
  dif.hours = (x2 - x1) / 60;
  return dif;
}
ostream &operator<<(ostream &out, Timer &t)
{
  out << t.hours << "hours," << t.minutes << "minutes";
  return out;
}
istream &operator>>(istream &in, Timer &t)
{
  cout << "Input hours and minutes:";
  in >> t.hours >> t.minutes;
  return in;
}
int main()
{
  Timer t1, t2, t3, t4;
  cin >> t1 >> t2;
  cout << "t1 = " << t1 << "\n";
  cout << "t2 = " << t2 << "\n";
  t3 = t1 + t2;
  cout << "t3 = t1 + t2 = " << t3 << "\n";
  t4 = t1 - t2;
  cout << "t4 = t1 - t2 = " << t4 << "\n";
  return 0;
}
